package com.nd.test.service;

import java.util.List;
import java.util.Date;

import model.po.RoleModel;
import com.nd.test.vo.RoleModelVo;
import com.nd.test.repository.RoleModelRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**   
 * Create by apisdk 
 */
@Service
public class RoleModelService {
	@Autowired
	private RoleModelRepository roleModelRepository;

	/**
	* @description create model
	* @return
	*/
	public RoleModelVo createRoleModel(RoleModelVo roleModelVo) throws Exception {
		RoleModel roleModel = new RoleModel();
		BeanUtils.copyProperties(roleModelVo, roleModel);
		roleModel =  roleModelRepository.save(roleModel);
		BeanUtils.copyProperties(roleModel, roleModelVo);
		return roleModelVo;
	}

	/**
	* @description get model through id
	* @return
	*/
	public List<RoleModelVo></Vo> getRoleModelByExample(RoleModelVo roleModelVo){
		RoleModel roleModel = new RoleModel();
		BeanUtils.copyProperties(roleModelVo, roleModel);
	}

	/**
	* @description update model through id
	* @return
	*/
	public RoleModelVo updateRoleModelById(@PathVariable String id,@RequestBody RoleModelVo roleModelVo){
		//TODO to finish update code
		return roleModelVo;
	}

	/**
	* @description delete model through id
	* @return
	*/
	public void deleteRoleModelById(@PathVariable String id){
		RoleModel roleModel =  roleModelRepository.findOne(id);
		if(roleModel!=null){
			roleModelRepository.delete(roleModel);
		}
		return;
	}

}
